﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dpdw.Behaviour.TemplateMethod
{
    /// <summary>
    /// 咖啡因饮料类
    /// </summary>
    public abstract class CaffeineBeverage
    {
        /// <summary>
        /// 准备配方
        /// </summary>
        public void PrepareRecipe()
        {
            BoilWater();

            Brew();

            PourInCup();

            if (CustomerWantsCondiments())
            {
                AddCondiments();
            }
        }

        /// <summary>
        /// 烧水
        /// </summary>
        public void BoilWater()
        {
            System.Diagnostics.Trace.WriteLine("CaffeineBeverage BoilWater");
        }

        /// <summary>
        /// 冲泡
        /// </summary>
        public abstract void Brew();

        /// <summary>
        /// 倒入杯子
        /// </summary>
        private void PourInCup()
        {
            System.Diagnostics.Trace.WriteLine("CaffeineBeverage PourInCup");
        }

        /// <summary>
        /// 加调料
        /// </summary>
        public abstract void AddCondiments();

        /// <summary>
        /// 顾客是否需要调料
        /// </summary>
        /// <returns></returns>
        public virtual bool CustomerWantsCondiments()
        {
            return true;
        }
    }
}
